home *** CD-ROM | disk | FTP | other *** search
Wrap
# Source Generated with Decompyle++ # File: in.pyc (Python 2.6) from gimpfu import * gettext.install('gimp20-python', gimp.locale_directory, unicode = True) def palette_sort(palette, model, channel, ascending): editable = pdb.gimp_palette_is_editable(palette) if not editable: palette = pdb.gimp_palette_duplicate(palette) num_colors = pdb.gimp_palette_get_info(palette) entry_list = [] for i in xrange(num_colors): entry = (pdb.gimp_palette_entry_get_name(palette, i), pdb.gimp_palette_entry_get_color(palette, i)) index = entry[1][channel] if model == 'HSV': index = entry[1].to_hsv()[channel] else: index = entry[1][channel] entry_list.append((index, entry)) entry_list.sort((lambda x, y: cmp(x[0], y[0]))) if not ascending: entry_list.reverse() for i in xrange(num_colors): pdb.gimp_palette_entry_set_name(palette, i, entry_list[i][1][0]) pdb.gimp_palette_entry_set_color(palette, i, entry_list[i][1][1]) return palette register('python-fu-palette-sort', N_('Sort the colors in a palette'), 'palette_merge (palette, model, channel, ascending) -> new_palette', 'Joao S. O. Bueno Calligaris, Carol Spears', 'Joao S. O. Bueno Calligaris', '2006', N_('_Sort Palette...'), '', [ (PF_PALETTE, 'palette', _('Palette'), ''), (PF_RADIO, 'model', _('Color _model'), 'HSV', ((_('RGB'), 'RGB'), (_('HSV'), 'HSV'))), (PF_RADIO, 'channel', _('Channel to _sort'), 2, ((_('Red or Hue'), 0), (_('Green or Saturation'), 1), (_('Blue or Value'), 2))), (PF_BOOL, 'ascending', _('_Ascending'), True)], [], palette_sort, menu = '<Palettes>', domain = ('gimp20-python', gimp.locale_directory)) main()